package net.sourceforge.peertwitter.scamp.messaging;

import net.sourceforge.peertwitter.core.applications.communication.messaging.ReliableMessage;
import rice.p2p.commonapi.NodeHandleSet;

public class ScampReliableMessage extends ScampMessage implements ReliableMessage {
	private static final long serialVersionUID = 8846309774507513150L;
	private final NodeHandleSet receivers;
	private final ScampMessage message;

	public ScampReliableMessage(ScampMessage message, NodeHandleSet receivers) {
		super(message.getGroup(),message.getSender());
		this.receivers = receivers;
		this.message = message;
	}

	public ScampMessage getMessage() {
		return this.message;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((message == null) ? 0 : message.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		ScampReliableMessage other = (ScampReliableMessage) obj;
		if (message == null) {
			if (other.message != null) {
				return false;
			}
		} else if (!message.equals(other.message)) {
			return false;
		}
		return true;
	}

	public NodeHandleSet getReceivers() {
		return receivers;
	}

//	@Override
//	public short getType() {
//		return ScampMessageTypes.RELIABLE_MESSAGE.type();
//	}
//
//	@Override
//	public void serialize(OutputBuffer buf) throws IOException {
//		// TODO Auto-generated method stub
//		
//	}
	
	
}
